package com.java.design;

/**
 * 外观模式没有涉及到接口的，它是为了解决类和类之间的耦合性，每一个类单独创建，然后再统一总的类进行串联起来，
 * 就好像spring一样，类和类之间的关系放在配置文件中，而外观模式是将类和类之间的放在一个类中的。这些类可能具有同名的方法
 * 
 * @author Administrator
 *
 */

class CPU {

	public void startup() {
		System.out.println("cpu startup!");
	}

	public void shutdown() {
		System.out.println("cpu shutdown!");
	}
}

class Disk {

	public void startup() {
		System.out.println("disk startup!");
	}

	public void shutdown() {
		System.out.println("disk shutdown!");
	}
}

class Memory {

	public void startup() {
		System.out.println("memory startup!");
	}

	public void shutdown() {
		System.out.println("memory shutdown!");
	}
}

class Computer {
	private CPU cpu;
	private Memory memory;
	private Disk disk;

	public Computer() {
		cpu = new CPU();
		memory = new Memory();
		disk = new Disk();
	}

	public void startup() {
		System.out.println("start the computer!");
		cpu.startup();
		memory.startup();
		disk.startup();
		System.out.println("start computer finished!");
	}

	public void shutdown() {
		System.out.println("begin to close the computer!");
		cpu.shutdown();
		memory.shutdown();
		disk.shutdown();
		System.out.println("computer closed!");
	}
}

public class FacadeMode {
	public static void main(String[] args) {
		Computer computer = new Computer();
		computer.startup();
		computer.shutdown();
	}
}
